<?php
class Form_Product extends Zend_Form {
	public function __construct(Model_Product $product)
	{
		parent::__construct();
		
		$this->setName('product');
		
		$this->setAction('/product/edit/id/' . $product->id);

		$brand = new Zend_Form_Element_Text('brand', array('label'=>'Брэнд'));
		
		$class = new Zend_Form_Element_Text('class', array('label'=>'Класс товара'));
		
		$material =  new Zend_Form_Element_Text('material', array('label'=>'Материал'));
		
		$gender =  new Zend_Form_Element_Select('gender', array('label'=>'Пол'));
		$gender->addMultiOptions(array('Детск.'=>'Детская','Муж.'=>'Мужская','Жен.'=>'Женская')); 
		$size = new Zend_Form_Element_Text('size', array('label'=>'Размер'));
		
		$seazon =  new Zend_Form_Element_Text('seazon', array('label'=>'Cезон'));
		
		$delivery =  new Zend_Form_Element_Text('delivery', array('label'=>'delivery'));
		
		$parentCategory = new Zend_Form_Element_Select('category_id', array('label'=>'Категория товара'));
		
		$category = new Model_Category();
		$categoryMapper = new Model_Category_Mapper();
		foreach ($categoryMapper->getAll() as $category){
			$parentCategory->addMultiOption($category->id, $category->name);
		}
		$parentCategory->setValue($product->category_id);
		
		$submit = new Zend_Form_Element_Submit('submit');
		
		$this->addElements(array($brand, $class, $material, $gender, $size, $seazon,  $parentCategory, $submit));
		$this->populate($product->toArray());
		
	}
}